package JUC;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @author 豆包LU
 * @date 2023/5/23 11:57
 */
public class OrderedThreadExecution3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> future1 = CompletableFuture.runAsync(() -> {
            System.out.println("T1");
        });

        CompletableFuture<Void> future2 = future1.thenRun(() -> {
            System.out.println("T2");
        });

        CompletableFuture<Void> future3 = future2.thenRun(() -> {
            System.out.println("T3");
        });

        // 等待所有任务完成
        future3.get();
    }
}
